package cn.yhbk.web.modules.manager.Service.Impl;

import cn.yhbk.web.modules.manager.Pojo.Entity.TbItemsLevela;
import cn.yhbk.web.modules.manager.Mapper.TbItemsLevelaMapper;
import cn.yhbk.web.modules.manager.Service.ITbItemsLevelaService;
import cn.yhbk.web.modules.manager.Service.ITbItemsService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 有何不可
 * @since 2024-02-04
 */
@Service
@Slf4j
public class TbItemsLevelaServiceImpl extends ServiceImpl<TbItemsLevelaMapper, TbItemsLevela> implements ITbItemsLevelaService {


    @Autowired
    ITbItemsService itemsService;


    @Override
    public Double getGpaNum( String grade, String level) {

        LambdaQueryWrapper<TbItemsLevela> lambda = new QueryWrapper<TbItemsLevela>().lambda();

        lambda.eq(TbItemsLevela::getLevel,level);
        lambda.eq(TbItemsLevela::getGrade,grade);

        List<TbItemsLevela> list = list(lambda);
        if(list.isEmpty()){
            log.error("未查询");
            return 0D;
        }
        return list.get(0).getGpa();
    }
}
